﻿/* ***************************************************************************************
 * Linq To SystemSearch
 * 
 *
 * This is an example of how extend LinQ using IQueruable and IOrderedQuerable interfaces.
 * 
 * User this code as you want,  is free.
 * 
 * Develop by: Mario Rodriguez
 * email: marior666@hotmail.com
 * 
 ********************************************************************************************/

using System.Collections.Generic;
using System.Linq.Expressions;
using System.Data;

namespace System.Search.Linq
{
    class SystemIndexDSQuery<T>
    {
        private Expression expression;

        

        public SystemIndexDSQuery(Expression e)
        {
            expression = e;
        }
        public static SystemIndexDSQuery<T> Parse(Expression expression)
        {
            return new SystemIndexDSQuery<T>(expression);
        }

        public IEnumerator<T> Execute()
        {

            
            QueryParser<T> parser = new QueryParser<T>(expression, this);
            
           

            return parser.Parse().Items;
        }

        public DataSet ExecuteDataSet()
        {


            QueryParser<T> parser = new QueryParser<T>(expression, this);



            return parser.Parse().DataSet;
        }

        public Query<T> ExecuteQuery()
        {


            QueryParser<T> parser = new QueryParser<T>(expression, this);



            return parser.Parse();
        }
    }
}
